package norbert.flickr.api {
	public class Url {
		public static function getPhotoSourceUrl(photo: XML, size: String = null): String {
			if (photo) {
				return getSourceUrl(photo.@id, photo.@secret, photo.@farm, photo.@server, size);
			} else {
				return null;
			}
		}

		public static function getPhotoSetSourceUrl(photoSet: XML, size: String = null): String {
			if (photoSet) {
				return getSourceUrl(photoSet.@primary, photoSet.@secret, photoSet.@farm, photoSet.@server, size);
			} else {
				return null;
			}
		}
		
		private static function getSourceUrl(id: uint, secret: String, farm: uint, server: uint, size: String = null): String {
			return "http://farm" + farm + ".static.flickr.com/" + server  + "/" + id + "_" + secret
				+ (size != null && size != "" ? ("_" + size) : "")
				+".jpg"
			;
		}

	}
}
